
<h1><span class="yiyi-st" id="yiyi-13">numpy.ma.resize</span></h1>
        <blockquote>
        <p>原文：<a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.ma.resize.html">https://docs.scipy.org/doc/numpy/reference/generated/numpy.ma.resize.html</a></p>
        <p>译者：<a href="https://github.com/wizardforcel">飞龙</a> <a href="http://usyiyi.cn/">UsyiyiCN</a></p>
        <p>校对：（虚位以待）</p>
        </blockquote>
    
<dl class="function">
<dt id="numpy.ma.resize"><span class="yiyi-st" id="yiyi-14"> <code class="descclassname">numpy.ma.</code><code class="descname">resize</code><span class="sig-paren">(</span><em>x</em>, <em>new_shape</em><span class="sig-paren">)</span><a class="reference external" href="http://github.com/numpy/numpy/blob/v1.11.3/numpy/ma/core.py#L6827-L6888"><span class="viewcode-link">[source]</span></a></span></dt>
<dd><p><span class="yiyi-st" id="yiyi-15">返回具有指定大小和形状的新的蒙版数组。</span></p>
<p><span class="yiyi-st" id="yiyi-16">这是<a class="reference internal" href="numpy.resize.html#numpy.resize" title="numpy.resize"><code class="xref py py-obj docutils literal"><span class="pre">numpy.resize</span></code></a>函数的屏蔽等效项。</span><span class="yiyi-st" id="yiyi-17">新数组用<em class="xref py py-obj">x</em>的重复副本填充（以数据存储在存储器中的顺序）。</span><span class="yiyi-st" id="yiyi-18">如果<em class="xref py py-obj">x</em>被屏蔽，新的数组将被屏蔽，新的屏蔽将是旧的数组的重复。</span></p>
<div class="admonition seealso">
<p class="first admonition-title"><span class="yiyi-st" id="yiyi-19">也可以看看</span></p>
<dl class="last docutils">
<dt><span class="yiyi-st" id="yiyi-20"><a class="reference internal" href="numpy.resize.html#numpy.resize" title="numpy.resize"><code class="xref py py-obj docutils literal"><span class="pre">numpy.resize</span></code></a></span></dt>
<dd><span class="yiyi-st" id="yiyi-21">顶层NumPy模块中的等效函数。</span></dd>
</dl>
</div>
<p class="rubric"><span class="yiyi-st" id="yiyi-22">例子</span></p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">numpy.ma</span> <span class="k">as</span> <span class="nn">ma</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">ma</span><span class="o">.</span><span class="n">array</span><span class="p">([[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">]</span> <span class="p">,[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">]])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">ma</span><span class="o">.</span><span class="n">masked</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span>
<span class="go">masked_array(data =</span>
<span class="go"> [[1 --]</span>
<span class="go"> [3 4]],</span>
<span class="go">             mask =</span>
<span class="go"> [[False  True]</span>
<span class="go"> [False False]],</span>
<span class="go">       fill_value = 999999)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">resize</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>
<span class="go">array([[1, 2, 3],</span>
<span class="go">       [4, 1, 2],</span>
<span class="go">       [3, 4, 1]])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ma</span><span class="o">.</span><span class="n">resize</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>
<span class="go">masked_array(data =</span>
<span class="go"> [[1 -- 3]</span>
<span class="go"> [4 1 --]</span>
<span class="go"> [3 4 1]],</span>
<span class="go">             mask =</span>
<span class="go"> [[False  True False]</span>
<span class="go"> [False False  True]</span>
<span class="go"> [False False False]],</span>
<span class="go">       fill_value = 999999)</span>
</pre></div>
</div>
<p><span class="yiyi-st" id="yiyi-23">无论输入类型如何，始终返回MaskedArray。</span></p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">]</span> <span class="p">,[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">]])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ma</span><span class="o">.</span><span class="n">resize</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>
<span class="go">masked_array(data =</span>
<span class="go"> [[1 2 3]</span>
<span class="go"> [4 1 2]</span>
<span class="go"> [3 4 1]],</span>
<span class="go">             mask =</span>
<span class="go"> False,</span>
<span class="go">       fill_value = 999999)</span>
</pre></div>
</div>
</dd></dl>
